<?php
abstract class BaseView extends Object{

	public static $TMPL="tmpl";
	
	function display(){
		$this->setDefaultView();
		$this->setRequestedView();
		$path=$this->getViewPath();
		ob_start();
	    require_once($path);
	    $content=ob_get_contents();
	    ob_end_clean();
	    $this->set("output",$content);
	}
	
	function setDefaultView(){
		$this->set("defaultView",Request::getVar("com"));
	}
	
	function setRequestedView(){
		$this->set("requestedView",Request::getVar("view",Request::getVar("com")));
	}
	
	function getViewPath(){
		$view=$this->get("requestedView");
		$path=$this->path.DIRSEP.self::$TMPL.DIRSEP.$view.".php";	
		$file=new File($path);
		if(!$file->fileReadable())
			$path=$this->path.DIRSEP.self::$TMPL.DIRSEP.Request::getVar("com").".php";
		return $path;
	}
	
}
?>